page.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. import { Metadata } from "next";
  2. import { NotionPage } from "@/components/notion-page";
  3. import { getPageContent } from "@/lib/notion";
  4. import { siteConfig } from "@/config/site";
  5. export const revalidate = 3600;
  6. export async function generateMetadata({
  7. params,
  8. }: {
  9. params: Promise<{ blogId: string }>;
  10. }): Promise<Metadata> {
  11. const { blogId } = await params;
  12. const { title } = await getPageContent(blogId);
  13. const postTitle = title || "Blog Post";
  14. return {
  15. title: postTitle,
  16. description: `${postTitle} - by ${siteConfig.author}`,
  17. alternates: {
  18. canonical: `/blog/${blogId}`,
  19. },
  20. openGraph: {
  21. title: postTitle,
  22. description: `${postTitle} - by ${siteConfig.author}`,
  23. type: "article",
  24. url: `/blog/${blogId}`,
  25. authors: [siteConfig.author],
  26. },
  27. twitter: {
  28. card: "summary_large_image",
  29. title: postTitle,
  30. description: `${postTitle} - by ${siteConfig.author}`,
  31. },
  32. };
  33. }
  34. export default async function Page({
  35. params,
  36. }: {
  37. params: Promise<{ blogId: string }>;
  38. }) {
  39. const { blogId } = await params;
  40. const { recordMap, title } = await getPageContent(blogId);
  41. const jsonLd = {
  42. "@context": "https://schema.org",
  43. "@type": "Article",
  44. headline: title,
  45. author: {
  46. "@type": "Person",
  47. name: siteConfig.author,
  48. url: siteConfig.url,
  49. },
  50. publisher: {
  51. "@type": "Person",
  52. name: siteConfig.author,
  53. url: siteConfig.url,
  54. },
  55. url: `${siteConfig.url}/blog/${blogId}`,
  56. };
  57. return (
  58. <>
  59. <script
  60. type="application/ld+json"
  61. dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
  62. />
  63. <NotionPage
  64. recordMap={recordMap}
  65. rootPageId={blogId}
  66. title={title ?? undefined}
  67. />
  68. </>
  69. );
  70. }